<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>销售审核</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../../res/css/wholesale/font.css">
  <link rel="stylesheet" href="../../res/css/wholesale/xadmin.css">
  <link rel="stylesheet" href="../../res/layui/css/layui.css">
  <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  <script type="text/javascript" src="../../res/layui/layui.js" charset="utf-8"></script>
  <script type="text/javascript" src="../../res/js/wholesale/xadmin.js"></script>
</head>
<body>
<div class="demoTable" style="margin-top: 10px;">
    <div class="x-body" >
      <div class="layui-row">
        <div class="layui-form layui-col-md12 x-so">
          <input type="text" name="sellId" id="sellId"   placeholder="销售订单号" autocomplete="off" class="layui-input"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
          <input type="text" name="sellTarget" id="sellTarget"   placeholder="销售人" autocomplete="off" class="layui-input"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
          <input type="date" name="startTime" id="startTime"   placeholder="销售开始时间" autocomplete="off" class="layui-input"> ——
          <input type="date" name="endTime" id="endTime"   placeholder="销售结束时间" autocomplete="off" class="layui-input"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
          <button class="layui-btn" data-type="reload" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </div>
      </div>
<table class="layui-table"  lay-data="{url:'../../listenSell/selectState.action', page:true, id:'idTest'}" lay-filter="demo">
  <thead>
    <tr>
      <th lay-data="{field:'sellTime', align:'center', templet: '#sellTime'}">销售时间</th>
      <th lay-data="{field:'sellPrice',  align:'center'}">销售总金额</th>
      <th lay-data="{field:'sellNumber', align:'center'}">销售总数量</th>
      <th lay-data="{field:'companyName',  align:'center'}">销售对象</th>	
      <th lay-data="{field:'operation',  align:'center', toolbar: '#barDemo'}">操作</th>
    </tr>
  </thead>
</table>
 </div>
 </div>
<script src="../../res/js/wj/common.js" charset="utf-8"></script>
<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="audit">审核</a>
</script>
 
 <script type="text/html" id="sellTime">
  {{ formatDate(d.sellTime) }}  
</script>
<script type="text/html" id="operationTime">
  {{ formatDate(d.openTime) }}  
</script>

<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
layui.use('table', function(){
  var table = layui.table;
  
  //监听表格复选框选择
  table.on('checkbox(demo)', function(obj){
    console.log(obj)
  });
  //表单重载
  var $ = layui.$, active = {
		    reload: function(){
			      var sellId = $('#sellId');
			      var sellTarget = $('#sellTarget');
			      var oper = $('#oper');
			      var startTime = $('#startTime');
			      var endTime = $('#endTime');
		      //执行重载    查询
		      table.reload('idTest', {
		        page: {
		          curr: 1 //重新从第 1 页开始
		        }
		        ,where: {
		        	sellId: sellId.val(),
		        	sellTarget: sellTarget.val(),
		        	oper: oper.val(),
		        	startTime: startTime.val(),
		        	endTime: endTime.val()
		        }
		      });
		    }
		  };
  
  
//监听工具条
  table.on('tool(demo)', function(obj){
    var da = obj.data;
    //删除
    if(obj.event === 'audit'){
    	layer.open({
  		  type: 2, //设置为iframe
  		  area: ['40%', '55%'],
  		  content: ['../../pages/sellAudit/audit.html?id='+da.sellId+'&ids='+da.sort+'', 'no'] //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
  		  ,end: function(){ 
  		  }
  		  ,success: function(layero, index){
  			  iframe.load();
  		  }
  	  }); 
    //修改
    } else if(obj.event === 'detail'){
    	
    	layer.open({
    		  type: 2, //设置为iframe
    		  area: ['70%', '60%'],
    		  content: ['../../pages/ListenSell/sellDetail.html?id='+da.sellId+'', 'no'] //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
    		  ,end: function(){ 
    		  }
    		  ,success: function(layero, index){
    			  iframe.load();
    		  }
    	  }); 
    }
  });
  $('.demoTable .layui-btn').on('click', function(){
    var type = $(this).data('type');
    active[type] ? active[type].call(this) : '';
  });
});

</script>
</body>
</html>